// Created by WXX on 2022/1/13 11:37
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

/**
 * 执行用时：0 ms, 在所有 C++ 提交中击败了100.00%的用户
 * 内存消耗：10.6 MB, 在所有 C++ 提交中击败了69.17%的用户
 */
class Solution {
public:
    int dominantIndex(vector<int>& nums) {

        int maxv = 0, index = -1;;
        for (int i = 0; i < nums.size(); i++) {
            if (nums[i] > maxv) {
                maxv = nums[i];
                index = i;
            }
        }
        for (auto x : nums) {
            if (x != maxv && maxv < x * 2)
                return -1;
        }
        return index;
    }
};

int main() {

    vector<int> nums = {3, 6, 0, 1};
    cout << Solution().dominantIndex(nums) << endl;  // 1

    return 0;
}
